<template>
  <NavBar>
    <div slot="left" class="el-icon-arrow-left" @click="backHome"></div>
    <div slot="center" class="titles">
      <div v-for="(title,index) in titles" class="title" :class="{active:index==currentIndex}" @click="titleClick(index)">{{title}}</div>
    </div>
  </NavBar>
</template>

<script>
  import NavBar from "components/common/navbar/NavBar";
  export default {
    name: "DetailNavBar",
    components:{
      NavBar
    },
    data(){
      return{
        titles:['商品','参数','评论','推荐'],
        currentIndex:0,
      }
    },
    methods:{
      backHome(){
        this.$router.back()
      },
      titleClick(index){
        this.currentIndex=index;
        this.$emit('titleClick',index)
      }
    }
  }
</script>

<style scoped>
  .el-icon-arrow-left {
    font-size: 25px;
    text-align: center;
    line-height: 44px;
    padding-left: 15px;
  }
  .titles {
    display: flex;
    margin: 0 5px;
  }
  .title {
    flex: 1;
  }
  .active {
    color: var(--color-high-text);
  }
</style>
